home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C & C++ Multimedia Cyber Classroom
/
C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso
/
src
/
fig14_11.jar
/
Ch14
/
Fig14_11
/
Fig14_11.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1997-11-04
|
564b
|
26 lines
// Fig. 14.11: fig14_11.cpp
// Creating a randomly accessed file sequentially
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
#include "clntdata.h"
int main()
{
ofstream outCredit( "credit.dat", ios::out );
if ( !outCredit ) {
cerr << "File could not be opened." << endl;
exit( 1 );
}
clientData blankClient = { 0, "", "", 0.0 };
for ( int i = 0; i < 100; i++ )
outCredit.write(
reinterpret_cast<const char *>( &blankClient ),
sizeof( clientData ) );
return 0;
}